
text = input("请输入一段文字：")

try:
    with open("D:\\hello.txt", "w", encoding="utf-8") as f:
        f.write(text)
    print("文字已成功保存到 D:\\hello.txt")
except Exception as e:
    print("保存文件时出错：", e)
